package com.yunshipei.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yunshipei.core.utils.SystemUtils;
import com.yunshipei.model.MainExtraBean;

import butterknife.ButterKnife;

public abstract class BaseBodyFragment extends Fragment {

    protected static final String ARGS_CUSTOMER_MAIN_DATA = "args.customer.main.data";

    protected Context mContext;
    protected MainExtraBean mMainExtraBean;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = getActivity();
        Bundle bundle = getArguments();
        if (bundle != null) {
            mMainExtraBean = (MainExtraBean) bundle.getSerializable(ARGS_CUSTOMER_MAIN_DATA);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(viewLayout(), container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    public abstract int viewLayout();

    public boolean isPad() {
        return SystemUtils.isPad(getActivity());
    }
}
